/*
 Copyright (c) 2013 MeherTJ G. All rights reserved.
 License: LGPL for personnal study or free software.
 */

#pragma once

/// 1. os
///
/// @ZEN_OS_WIN
/// @ZEN_OS_ANDROID
/// @ZEN_OS_APPLE
///   - @ZEN_OS_OSX
///   - @ZEN_OS_IOS
/// @ZEN_OS_UNIXLIKE

/// 2. endian byte order
///
/// @ZEN_BIG_ENDIAN
/// - always defined. if 0 : little endian.

/// 3. debug mode
///
/// @ZEN_DEBUG
/// - always defined. if 0 : not debug mode.

/// 4. visual gui
///
/// @ZEN_VISUAL
/// - always defined. if 0 : not gui program.

#include <cstdint>

// 1. os

// - windows
#if defined(_WIN32)
#define ZEN_OS_WIN 1

// - android
#elif defined(__ANDROID__)
#include "jni.h"
#define ZEN_OS_ANDROID 1

// - apple
#elif defined(__APPLE__)
#include <TargetConditionals.h>

#define ZEN_OS_APPLE 1

#if __has_feature(objc_arc)
#endif

// -- apple - mac
#if TARGET_OS_OSX

#define ZEN_OS_OSX 1

// -- apple - ios
#elif TARGET_OS_IPHONE
#define ZEN_OS_IOS 1
#endif

// - unixlike
#elif defined(__unix__) || defined(__posix__) || defined(__linux__) || defined(__FreeBSD__)
#define ZEN_OS_UNIXLIKE 1

#else

#define ZEN_OS_OTHER

#endif

// 2. endian

#if defined(ZEN_BIG_ENDIAN)
# if ZEN_BIG_ENDIAN
#   undef ZEN_BIG_ENDIAN
#   define ZEN_BIG_ENDIAN 1
# else
#   undef ZEN_BIG_ENDIAN
#   define ZEN_BIG_ENDIAN 0
# endif
#elif defined(__linux__)
# include <endian.h>
# if __BYTE_ORDER == __BIG_ENDIAN
#   define ZEN_BIG_ENDIAN 1
# else // if __BYTE_ORDER == __LITTLE_ENDIAN
#   define ZEN_BIG_ENDIAN 0
# endif
#elif defined(__hppa__) || defined(__m68k__) || defined(mc68000) || \
defined(_M_M68K) || (defined(__MIPS__) && defined(__MISPEB__)) || \
defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \
defined(__sparc__)

# define ZEN_BIG_ENDIAN 1
#else
# define ZEN_BIG_ENDIAN 0
#endif

// 3. debug mode

#if defined(ZEN_DEBUG)
# if ZEN_DEBUG
#	  undef ZEN_DEBUG
#	  define ZEN_DEBUG 1
# else
#   undef ZEN_DEBUG
#   define ZEN_DEBUG 0
# endif
#elif !defined(NO_DEBUG) && (defined(_DEBUG) || defined(DEBUG))
#	define ZEN_DEBUG 1
#else
# define ZEN_DEBUG 0
#endif

// 4. visual gui

#if defined(ZEN_VISUAL)
# if ZEN_VISUAL
#   undef ZEN_VISUAL
#   define ZEN_VISUAL 1
# else
#   undef ZEN_VISUAL
#   define ZEN_VISUAL 0
# endif

#elif ZEN_OS_IOS || ZEN_OS_ANDROID || defined(VISUAL)
// ios or android default 1
#	define ZEN_VISUAL 1
#else
// other platform default 0
#	define ZEN_VISUAL 0
#endif
